#include "mainwidge.h"
#include "ui_mainwidge.h"
#include <QPalette>
#include <QPainter>
#include "widget.h"
#include "login.h"
mainwidge::mainwidge(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::mainwidge)
{
    ui->setupUi(this);
    this->resize(800,500);//设置窗口大小
    this->setWindowTitle("贪吃蛇");
    this->setAutoFillBackground(true);
    //标签初始化
    this->label=new QLabel(this);
    label->setPixmap(QPixmap(":/qtthings/qc"));
    //添加按钮
    this->start=new QPushButton(this);
    this->start->setIcon(QIcon(":/qtthings/start"));
    this->start->setIconSize(QSize(220,150));
    this->start->setFlat(true);


    this->exit=new QPushButton(this);
    this->exit->setIcon(QIcon(":/qtthings/gg"));
    this->exit->setIconSize(QSize(220,120));
    this->exit->setFlat(true);



    this->setFocusPolicy(Qt::NoFocus);

    //创建一个垂直布局
    this->qv=new QVBoxLayout(this);
    this->qv->addWidget(label);
    this->qv->addWidget(start);
    this->qv->addWidget(exit);

    this->qv->setAlignment(Qt::AlignCenter);

    this->x = new Login;
    x->hide();
    this->connect(start,SIGNAL(clicked()),this,SLOT(startclick()));
    this->connect(exit,SIGNAL(clicked()),this,SLOT(close()));
}

mainwidge::~mainwidge()
{
    delete ui;
}
void mainwidge::paintEvent(QPaintEvent *event)
{
    QPainter  painter(this);
    QPixmap pig;
    pig.load(":/qtthings/RC");
    painter.drawPixmap(0,0,800,600,pig);
}
void mainwidge::startclick()
{
    x->show();
}
